/*
 * jQuery plugin for the CFmaker framework
 * the intention is to roll all client-side functionality (where ever it makes sense) in jQuery functions
 * we also utilize CFC proxies, which depend on the <cfajaxproxy> tags in the Application.cfc
 */

/*
 * this self-executor sets up the custom, jQuery functions
 */
(function($, appProxy, comProxy, dispProxy) {
	var app = new appProxy();
	var com = new comProxy();
	var disp = new dispProxy();
	
	$.fn.com = function(thisAttr) {
		var attr = thisAttr || "value"; 
		
		return this.each(function() {
			var val = eval("$(this)." + attr + "()");
			
		});
	}
	
	$.fn.display = function(viewName, args) {
		var argStr = "";
		var I = "";
		
		for (I in args) {
			argStr += "'" + args[I] + "',";
		}
		
		argStr = argStr.substr(0, argStr.length-1);	// strip off the trailing comma
		content = eval("app.disp." + viewName + "(" + argStr + ")");
		
		return this.html(content);
		
		return this.each(function() {
			// for now...later we check the element's type and replace it with a similar element
			$(this).html(loadingDiv);
			$(this).html(content);
		});
	}
	
/*	
	$.fn.myPlugin = function(settings) {
	     var config = {'foo': 'bar'};
	 
	     if (settings) $.extend(config, settings);
	 
	     this.each(function() {
	       // element-specific code here
	     });
	 
	     return this;
	 
	   };
*/
})(jQuery, applicationProxy, controllerProxy, displayProxy);